add option to capture valgrind output in a log file.
authortsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 31 Aug 2013 00:09:51 +0000 (00:09 +0000)
committertsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 31 Aug 2013 00:09:51 +0000 (00:09 +0000)
gpsbabel/vtesto

index 72f2dbb7b4abbae0c6e51d57d80154afd3b43804..4b286817f0a96ca24c0abc3358e0cfdd20628ed3 100755 (executable)
@@ -9,11 +9,20 @@
 QUIET="-q"
 BASEPATH=`dirname $0`
 
-while getopts "l" opt; do
+while getopts "lj:" opt; do
   case $opt in
     l) OPTS="--leak-check=full --show-reachable=yes --suppressions=gpsbabel.supp" ; QUIET="";;
+    j) LOG=$OPTARG;;
   esac
 done
 shift $(($OPTIND -1))
 
-PNAME="valgrind $OPTS --error-exitcode=1 $QUIET ./gpsbabel" ${BASEPATH}/testo $*
+if [ "x$LOG" = "x" ]; then
+  PNAME="valgrind $OPTS --error-exitcode=125 $QUIET            ./gpsbabel" ${BASEPATH}/testo $*
+else
+# By default valgrind output goes to file descriptor 2, stderr.
+# Some of our tests redirect file descriptor 2 to a file and compare it to an expected result.
+# These compares will fail if valgrind sends output to file descriptor 2.
+# This option avoids those valgrind induced miscompares by using an alternate file descriptor.
+  PNAME="valgrind $OPTS --error-exitcode=125 $QUIET --log-fd=3 ./gpsbabel" ${BASEPATH}/testo $* 3>$LOG
+fi